<template>
    <el-dialog
        title="审核项目"
        :visible.sync="dialogVisible"
        size="60%"
        custom-class="search-result-pop title-list"
        :before-close="handleClose">
        <div class="audit-project">
            <FormGroup v-if="addColumnConfig" style="margin-top: 20px" :searchConfig="addColumnConfig" ref="formParams" labelWidth="120px" labelPosition="right" />
        </div>
        <div class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="handleConfirm" style="margin-left: 50px">确 定</el-button>
        </div>
        
    </el-dialog>
</template>
<script>
import { updateMessageTypeSort } from '@/api/inner-msg/index.js';
import FormGroup from '@/views/components/FormGroup';
import { auditPro } from './../api'
const formConfig = [
    {
        type: 'content',
        value: '数据分析项目',
        label: '当前项目',
        keyIndex: 'name',
        placeholder: '输入名称。10字以内',
        span: 24,
        inputWidth: '300px',
        maxlength: 10,
        showWordLimit: true,
        inputType: 'text'
    },
    {
        type: 'radio',
        value: '0',
        label: '审核',
        keyIndex: 'status',
        span: 24,
        options: [
            {
                value: '1',
                label: '通过'
            },
            {
                value: '0',
                label: '驳回'
            }
        ]
    },
    {
        type: 'textarea',
        value: '',
        label: '备注',
        keyIndex: 'name',
        placeholder: '输入备注。500字以内',
        span: 24,
        inputWidth: '300px',
        maxlength: 500,
        showWordLimit: true,
        rows: 5
    },
]
export default {
    name: "DragSrot",
    props: ['TYPE'],
    components: { FormGroup },
    data() {
        return {
            dialogVisible: false,
            tableList: [],
            auditRadio: '',
            addColumnConfig: null,
            currentId: ''
        };
    },
    methods: {
        handleClose() {
            this.dialogVisible = false;
            this.tableList = [];
            this.$dragging.$off("dragged");
        },
        open({ title, id }) {
            this.currentId = id;
            this.dialogVisible = true;
            const newConfig = JSON.parse(JSON.stringify(formConfig));
            newConfig[0].value = title;
            this.addColumnConfig = newConfig;
        },
        async handleConfirm() {
            const ids = this.tableList.map(v => v.id);
            const { code, msg } = await auditPro({
                "examineNotes": this.addColumnConfig[2].value,
                "examineStatus": this.addColumnConfig[1].value,
                "id": this.currentId
            });
            if (code !== 0) {
                this.$message.error(msg);
                return;
            }
            this.$message.success('驳回成功');
            this.handleClose();
            this.$emit('success');
        }
    },
    mounted() {
        // 拖拽事件
        this.$dragging.$on("dragged", (result) => {
            // 将排序后的结果重新赋值
            this.tableList = result.value.list;
        });
    },
    beforeDestroy() {
        this.$dragging.$off("dragged");
    }
};
</script>
 
<style lang="scss" scoped>
    .title-list {
        background:#fff;
        margin:100px auto 0;
        border: 1px solid red;

        .audit-project {

        }
        .dialog-footer {
            margin-top: 20px;
            text-align: center;
        }
        
    }
</style>